package com.tte.common.controller;

import com.tte.common.model.tenum.ResultCode;
import com.tte.common.model.vo.RequestModel;
import com.tte.common.model.vo.ResponseModel;
import com.tte.common.model.vo.ResultBean;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 使用spring自带的BeanUtils转换
 * @Author: DongWH
 * @Date: 2024/3/11 14:41
 */
@RestController
@RequestMapping("/beanUtils")
public class BeanUtilsController {

    /**
     * 使用spring自带的BeanUtils转换
     * @param requestModel
     * @return
     */
    @PostMapping("/copyProperties")
    public ResultBean VoConvert(@RequestBody RequestModel requestModel){
        ResponseModel responseModel = new ResponseModel();
        BeanUtils.copyProperties(requestModel, responseModel);
        return new ResultBean(ResultCode.OK,responseModel);
    }

}
